import { View, Text, Image, RichText, WebView } from "@tarojs/components";
import Taro, { useLoad } from "@tarojs/taro";
import { Button, Cell, CellGroup } from "@nutui/nutui-react-taro";
import { c } from "../../common/index.js";
import { useState } from "react";
import { navigateTo } from "../../common/_.js";
import { selectMiniInfoById } from "../../api/zixun.js";
import "./index.scss";

export default function ZixunDetail() {

  const [detail,setDetail] = useState('')
  const [isConnect,setIsConnect] = useState('')
  useLoad(() => {
    let id = c.getParams().id;
    getDetail(id)
  });

  async function getDetail(id){
    const {data,success} = await selectMiniInfoById({id})
    
    // data.infoContent = data.infoContent.replace(/\<img/g, "<img style='width: 100%;heigth:auto'")

    success && setDetail(data.infoContent)
    success && setIsConnect(data.isConnect)
    
  }


  return (
    <View className="wrap">
      {
        isConnect === 1 ? <WebView src={detail}  />
        :
        <RichText nodes={detail}/>
      }

{/* <View dangerouslySetInnerHTML={{ __html: detail}} /> */}
      
       {/* <RichText nodes={htmlStr} /> */}
       {/* <View dangerouslySetInnerHTML={{ __html: detail}} /> */}
       {/* <WebView src={detail}  /> */}
    </View>
  );
}
